﻿namespace ChessToys
{
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// <see cref="IMoveGenerator"/> for <see cref="Queen"/>.
    /// </summary>
    public class QueenMoveGenerator : AbstractPieceMoveGenerator<Queen>
    {
        private IMoveGenerator _rockMockGenerator = new RockMoveGenerator();
        private IMoveGenerator _bishopMoveGenerator = new BishopMoveGenerator();

        /// <inheritdoc />
        protected override ISet<Move> GenerateForSpecificPiece(Board board, Position start, Queen piece)
        {
            ISet<Move> moves = new HashSet<Move>();
            // get rock moves
            board[start] = new Rock(piece.Color);
            moves.UnionWith(_rockMockGenerator.Generate(board, start));
            // get bishop moves
            board[start] = new Bishop(piece.Color);
            moves.UnionWith(_bishopMoveGenerator.Generate(board, start));
            // revert board changes
            board[start] = piece;
            // result
            return moves;
        }
    }
}
